<style lang="scss" scoped>
  @import '../../../styles/common/loading.less';
  .container{
    border: none !important;
    margin-top: 4px;
  }
  .el-col-offset-1 {
    margin-left: 0%;
  }
  .button_a {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);

  }
  .col_a {
    margin-left: 2%;
  }
  .el-card {
    height: 200px;
  }

  .el-button--primary {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);
  }
</style>
<template>
  <div  class="common-background-color">
    <div style="width:98%;height:100%;margin: 6px 12px;">
      <el-collapse v-model="activeNames" v-if="this.item===0||this.item===1" @change="handleChange"  class="coll_a">
        <el-collapse-item title="药品目录管理信息"  name="1">
          <el-form :model="list" :rules="rules" ref="list" class="info-submit-form">
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="comName" label="归属机构" >
                  <el-autocomplete
                    popper-class="my-autocomplete"
                    v-model="list.comName"
                    :fetch-suggestions="querySearchAsync"
                    placeholder="请输入内容"
                    @select="handleSelect">
                    <template slot-scope="{ item }">
                      <div>{{ item.code }}-{{ item.value }}</div>
                    </template>
                  </el-autocomplete>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsCode" label="药品编码" >
                  <el-input  v-model="list.drugsCode" @input="drugsCodeInput" ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsName" label="中文名称" >
                  <el-input  @input="drugsNameInput" v-model="list.drugsName"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="drugsEName" label="英文名称" >
                  <el-input v-model="list.drugsEName"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="pinyinCode" label="拼音助记码" >
                  <el-input  disabled v-model="list.pinyinCode"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="wbxCode" label="五笔助记码" >
                  <el-input  disabled v-model="list.wbxCode"></el-input>
                </el-form-item>
              </el-col>

            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="customCode" label="自定义码" >
                  <el-input  v-model="list.customCode"></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item prop="prescribeFlag" label="处方药标志" >
                  <el-select v-model="list.prescribeFlag">
                    <el-option
                      v-for="item in PresFlag"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="dose" label="剂型" >
                  <el-select  v-model="list.dose">
                    <el-option value="" label="请选择"></el-option>
                    <el-option
                      v-for="item in DoseType"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="feesType" label="收费类别" >
                  <el-select  v-model="list.feesType">
                    <el-option value="" label="请选择"></el-option>
                    <el-option
                      v-for="item in ChargeCate"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="feesGrade" label="收费项目等级" >
                  <el-select  v-model="list.feesGrade">
                    <el-option value="" label="请选择"></el-option>
                    <el-option
                      v-for="item in ChargeItemLevel"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="doseUnit" label="药品剂量单位" >
                  <el-input  v-model="list.doseUnit"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="unit" label="单位" >
                  <el-input v-model="list.unit"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="medicineNo" label="使用频次" >
                  <el-input  v-model="list.medicineNo"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="routineDose" label="每次用量" >
                  <el-input  v-model="list.routineDose"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="limitDays" label="限定天数" >
                  <el-input v-model="list.limitDays"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsFactoryName" label="药厂名称" >
                  <el-input  v-model="list.drugsFactoryName"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="specifications" label="规格" >
                  <el-input  v-model="list.specifications"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="useMethod" label="用法" >
                  <el-input v-model="list.useMethod"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="characterCode" label="国药准字编码" >
                  <el-input v-model="list.characterCode"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="originPlace" label="产地" >
                  <el-select  v-model="list.originPlace">
                    <el-option
                      v-for="item in PlaceType"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="startDate" label="开始日期" >
                  <el-date-picker type="datetime" v-model="list.startDate" placeholder="选择日期时间"></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="endDate" label="终止日期" >
                  <el-date-picker type="datetime" v-model="list.endDate" placeholder="选择日期时间"></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsType" label="药品分类号" >
                  <el-input  v-model="list.drugsType"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="nationListCode" label="国家目录编码" >
                  <el-input   v-model="list.nationListCode"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsOneType" label="药物分级一" >
                  <el-input v-model="list.drugsOneType"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsTwoType" label="药物分级二" >
                  <el-input   v-model="list.drugsTwoType"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="drugPrice" label="药品价格" >
                  <el-input v-model="list.drugPrice"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="maxPrice" label="最高限价" >
                  <el-input v-model="list.maxPrice"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="perPayRatio" label="个人自付比例" >
                  <el-input  style="margin-top: 5px"  v-model="list.perPayRatio">
                    <template slot="append">%</template>
                  </el-input>
                </el-form-item>
              </el-col>

            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="drugsThreeType" label="药物分级三" >
                  <el-input v-model="list.drugsThreeType"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsFourType" label="药物分级四" >
                  <el-input v-model="list.drugsFourType"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="delFlag" label="有效标志" >
                  <el-select v-model="list.delFlag">
                    <el-option value="" label="请选择"></el-option>
                    <el-option
                      v-for="item in ValidFlag"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
            <el-col :span="8">
                <el-form-item prop="remark" label="备注" >
                  <el-input v-model="list.remark"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-collapse-item>
      </el-collapse>
      <el-collapse v-model="activeNames" v-if="this.item===2" @change="handleChange"  class="coll_a">
        <el-collapse-item title="药品目录管理信息"  name="1">
          <el-form :model="list" ref="list" label-width="100px">
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="comName" label="归属机构" >
                  <el-input disabled  v-model="list.comName" :span="8"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsCode" label="药品编码" >
                  <el-input  v-model="list.drugsCode" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsName" label="中文名称" >
                  <el-input  v-model="list.drugsName" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="drugsEName" label="英文名称" >
                  <el-input   v-model="list.drugsEName" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="pinyinCode" label="拼音助记码" >
                  <el-input  v-model="list.pinyinCode" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="wbxCode" label="五笔助记码" >
                  <el-input  v-model="list.wbxCode" disabled></el-input>
                </el-form-item>
              </el-col>

            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="customCode" label="自定义码" >
                  <el-input v-model="list.customCode" disabled></el-input>
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <el-form-item prop="prescribeFlag" label="处方药标志" >
                  <el-select  v-model="list.prescribeFlag" disabled>
                    <el-option
                      v-for="item in PresFlag"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="dose" label="剂型" >
                  <el-select v-model="list.dose" disabled>
                    <el-option value="" label="请选择"></el-option>
                    <el-option
                      v-for="item in DoseType"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="feesType" label="收费类别" >
                  <el-select v-model="list.feesType" disabled>
                    <el-option value="" label="请选择"></el-option>
                    <el-option
                      v-for="item in ChargeCate"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="feesGrade" label="收费项目等级" >
                  <el-select  v-model="list.feesGrade" disabled>
                    <el-option value="" label="请选择"></el-option>
                    <el-option
                      v-for="item in ChargeItemLevel"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="doseUnit" label="药品剂量单位" >
                  <el-input  v-model="list.doseUnit" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="unit" label="单位" >
                  <el-input v-model="list.unit" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="medicineNo" label="使用频次" >
                  <el-input  v-model="list.medicineNo" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="routineDose" label="每次用量" >
                  <el-input v-model="list.routineDose" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="limitDays" label="限定天数" >
                  <el-input v-model="list.limitDays" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsFactoryName" label="药厂名称" >
                  <el-input v-model="list.drugsFactoryName" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="specifications" label="规格" >
                  <el-input v-model="list.specifications" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="useMethod" label="用法" >
                  <el-input v-model="list.useMethod" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="characterCode" label="国药准字编码" >
                  <el-input v-model="list.characterCode" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="originPlace" label="产地" >
                  <el-select  v-model="list.originPlace" disabled>
                    <el-option
                      v-for="item in PlaceType"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="startDate" label="开始日期" >
                  <el-date-picker type="datetime" v-model="list.startDate" placeholder="选择日期时间" disabled></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="endDate" label="终止日期" >
                  <el-date-picker type="datetime" v-model="list.endDate" placeholder="选择日期时间" disabled></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsType" label="药品分类号" >
                  <el-input  v-model="list.drugsType" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="nationListCode" label="国家目录编码" >
                  <el-input v-model="list.nationListCode" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsOneType" label="药物分级一" >
                  <el-input  v-model="list.drugsOneType" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsTwoType" label="药物分级二" >
                  <el-input  v-model="list.drugsTwoType" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="drugPrice" label="药品价格" >
                  <el-input  disabled v-model="list.drugPrice"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="maxPrice" label="最高限价" >
                  <el-input  v-model="list.maxPrice" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="perPayRatio" label="个人自付比例" >
                  <el-input   style="margin-top: 5px" disabled v-model="list.perPayRatio">
                    <template slot="append">%</template>
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item prop="drugsThreeType" label="药物分级三" >
                  <el-input v-model="list.drugsThreeType" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="drugsFourType" label="药物分级四" >
                  <el-input v-model="list.drugsFourType" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item prop="delFlag" label="有效标志" >
                  <el-select  v-model="list.delFlag" disabled>
                    <el-option value="" label="请选择"></el-option>
                    <el-option
                      v-for="item in ValidFlag"
                      :key="item.codeCode"
                      :label="item.codeCName"
                      :value="item.codeCode">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
            <el-col :span="8">
                <el-form-item prop="remark" label="备注" >
                  <el-input  v-model="list.remark" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-collapse-item>
      </el-collapse>
    </div>
    <div>
      <template>
        <div slot="footer" style="text-align: center;height: 60px;line-height: 30px" class="dialog-footer">
          <el-button type="primary" v-if="this.item===0" @click="save('list')">提 交</el-button>
          <el-button type="primary" v-if="this.item===1" @click="handleEditUpdate('list')">提 交</el-button>
          <el-button type="primary" v-if="this.item===0" @click="resetForm('list')">重 置</el-button>
          <el-button type="primary" v-if="this.item===1" @click="fanhui">关 闭</el-button>
          <el-button type="info" v-if="this.item===2" @click="fanhui">关 闭</el-button>
        </div>
      </template>
    </div>
    <el-dialog
      :visible.sync="Successdialog"
      :show-close="false"
      :close-on-click-modal="true"
      :close-on-press-escape="false"
      width="20%"
      center>
      <div style="margin-top: -35px;">
        <div>| 药品目录管理</div>
        <hr style="width: 80%;margin-left: 1px">
      </div>
      <div v-if="this.item1===0" style="text-align: center;margin-top: 20px">
        <img src="../../../assets/images/pass.png" width="60">
        <div style="margin-top: 10px">{{this.message}}</div>
<!--        <div style="margin-top: 10px">大病赔案号：{{formInline.caseNo}}</div>-->
      </div>
      <div v-if="this.item1===1" style="text-align: center;margin-top: 20px">
        <img src="../../../assets/images/notPass.png" width="60">
        <div style="margin-top: 10px">提交失败</div>
<!--        <div style="margin-top: 10px">大病赔案号：{{formInline.caseNo}}</div>-->
      </div>
      <div style="margin-top: 15px;text-align: center"><span style="font-size: x-large">{{time}}</span>秒后跳转到上一个页面</div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="researchCheckSearch" type="text" :disabled= false >关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import * as api from '@/api/basicInformation'
  import * as api1 from '@/api/baseDate'
  export default {
    name: 'drugCatalogDemo',
    data() {
      var drugsNameDemo = (rule, value, callback) => {
          if (!value && !this.list.drugsEName) {
            callback(new Error('中文名称、英文名称不能同时为空'));
          }else {
            callback();
          }
        };
      var drugsENameDemo = (rule, value, callback) => {
        if (!this.list.drugsName && !value) {
          callback(new Error('中文名称、英文名称不能同时为空'));
        }else {
          callback();
        }
      }; // startDate
      var endDateDemo = (rule, value, callback) => {
        if (this.list.startDate > value) {
          callback(new Error('终止日期不能早于开始日期'));
        }else {
          callback();
        }
      };
      var checkAge = (rule, value, callback) => {
        if(!value){
          callback(new Error('药品编码不能为空'));
        }else {
          this.listDemo.map(item=>{
            if(item.drugsCode===value){
              // this.list.drugsCode=null;
              callback(new Error('该药品编码已存在，请重新输入！'));
            }
          })
        }
      };
      return {
        drugCatalog:[
          {comCode: "20000000000",comName:"总公司"},
          {comCode: "20020000000",comName:"江苏分公司"},
          {comCode: "20020100000",comName:"徐州中支公司"},
        ],
        rules:{ // 终止日期不能早于开始日期
          comName:[{ required: true, message: '归属机构不能为空', trigger: 'blur' },],
          // drugsCode:[{ required: true, message: '药品编码不能为空', trigger: 'blur' },],
          perPayRatio:[{ required: true, message: '个人自付比例不能为空', trigger: 'blur' },
            { pattern:/^(\d|[1-9]\d|100)(\.\d{1,2})?$/,message: '请输入0-100，且小数点后两位的数',trigger: 'blur'}
          ],
          drugsName:[{ validator: drugsNameDemo, trigger: 'blur' }],
          drugsEName:[{ validator: drugsENameDemo, trigger: 'blur' }],
          endDate:[{ validator: endDateDemo, trigger: 'blur' }],
          // drugsCode:[{ validator: checkAge, trigger: 'blur' }],
          // perPayRatio:[{ validator: checkAge, trigger: 'blur' }],
          drugPrice: [
            {required: true, message: "药品价格不能为空", trigger: "blur"},
            {pattern: /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/, message: "请输入数字，最多2位小数", trigger: "change"}
          ],
          maxPrice: [
            {required: true, message: "最高限价不能为空", trigger: "change"},
            {pattern: /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/, message: "请输入数字，最多2位小数", trigger: "change"}
          ],
          delFlag:[{ required: true, message: '有效标志不能为空', trigger: 'blur' },],
          feesGrade:[{ required: true, message: '收费项目等级不能为空', trigger: 'blur' },],
        },

        Successdialog:false,
        query: {
          address: '',
          name: '',
          pageIndex: 1,
          pageSize: 10
        },
        ValidFlag:[
          {
            codeCode:0,
            codeCName:'无效'
          },
          {
            codeCode:1,
            codeCName:'有效'
          },
        ],
        PlaceType:[
          {
            codeCode:'1',
            codeCName:'国产'
          },
          {
            codeCode:'2',
            codeCName:'进口'
          },
        ],
        PresFlag:[
          {
            codeCode:'0',
            codeCName:'非处方药'
          },
          {
            codeCode:'1',
            codeCName:'处方药'
          },
        ],
        DoseType:[],
        ChargeCate:[],
        ChargeItemLevel:[],
        dialogFormVisible:false,
        activeNames: ['1','2'],
        //控制显示隐藏
        isBase:false,
        isSurvey:false,
        shenheyijian:"1",
        activeName: 'first',
        multipleSelection: [],
        delList: [],
        editVisible: false,
        pageTotal: 0,
        list: {
        },
        formInline: {
          policy: '20143301000000008',
          startDate: '2019-01-01',
          endDate: '2022-01-01',
          insurePlan: '徐州医保局',
        },
        message:'',
        time:0,
        item:0,
        item1:0,
        listDemo:[],
      };
    },
    mounted() {
      this.restaurants=this.drugCatalog.map(item=>{
        return{
          code:item.comCode,
          value:item.comName,
        }
      })
    },
    created() {
      this.DoseType1(),
      this.ChargeCate1(),
      this.ChargeItemLevel1(),
      this.list=JSON.parse(this.$route.query.drugCatalogDemo)
      this.item=JSON.parse(this.$route.query.item)
      var data={
      }
      api.getQueryDrug(data
      ).then(res => {
        console.log("listDemo"+res)
        this.listDemo=res.data.list;
      })
      console.log("123"+this.list)
    },
    methods: { //
      drugsNameInput(res){
        this.list.pinyinCode=api.makePy(res)
        this.list.wbxCode =api.makeWb(res)
      },
      querySearchAsync(queryString, cb) {
        var restaurants = this.restaurants;
        var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;
        clearTimeout(this.timeout);
        this.timeout = setTimeout(() => {
          if (results.length === 0) {
            this.list.comName=null;
            cb(restaurants);
          } else {
            cb(results);
          }
        }, 1000 * Math.random());
      },
      createStateFilter(queryString) {
        return (state) => {
          // return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
          return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) > -1);
        };
      },
      comCode(comName){
        this.drugCatalog.forEach(item=>
          {
            if(comName===item.comName){
              this.list.comCode=item.comCode
            }
          }
        )
      },
      drugsCodeInput(drugsCode){
      },
      save(formName){
        this.$refs[formName].validate((valid) => {
          alert("123")
          if (valid) {
            alert("456")
            this.comCode(this.list.comName);
            api.getSaveDrug(this.list
            ).then(res => {
              this.message=res.data.resultMsg;
              this.Successdialog=true
              // 把time改为5
              this.time = 5;
              // 设定一个定时器，每一秒调用一次coundDown方法，time-1
              setInterval(this.countDown, 1000);
            }).catch((function () {
                /*let THIS = this;*/
                this.item1=1,
                  this.Successdialog=true
                // 把time改为5
                this.time = 5;
                // 设定一个定时器，每一秒调用一次coundDown方法，time-1
                setInterval(this.countDown, 1000);
              }),
            )
          } else {
            console.log('error submit!!');
            return false;
          }
        });

      },
      handleEditUpdate(formName){
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.comCode(this.list.comName);
            api.getUpdataDrug(this.list
            ).then(res => {
              this.message=res.data.resultMsg;
              this.Successdialog=true
              // 把time改为5
              this.time = 5;
              // 设定一个定时器，每一秒调用一次coundDown方法，time-1
              setInterval(this.countDown, 1000);
            }).catch((function () {
                /*let THIS = this;*/
                this.item1=1,
                  this.Successdialog=true
                // 把time改为5
                this.time = 5;
                // 设定一个定时器，每一秒调用一次coundDown方法，time-1
                setInterval(this.countDown, 1000);
              }),
            )
          } else {
            console.log('error submit!!');
            return false;
          }
        });

      },
      //剂型
      DoseType1(){
        var data={
          "codeType": "DoseType"
        }
        api1.MedType(data
        ).then(res => {
          // debugger
          this.DoseType=res.data
        })
      },
      // 收费类别
      ChargeCate1(){
        var data={
          "codeType": "ChargeCate"
        }
        api1.MedType(data
        ).then(res => {
          // debugger
          this.ChargeCate=res.data
        })
      },
      // 收费项目等级
      ChargeItemLevel1(){
        var data={
          "codeType": "ChargeItemLevel"
        }
        api1.MedType(data
        ).then(res => {
          // debugger
          this.ChargeItemLevel=res.data
        })
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
        this.reload();
      },
      fanhui(){
        this.Successdialog=false
        this.closePageTo(this.$store,this.$route,this.$router,'drugCatalog');
      },
      isBaseInfo(){
        this.isBase=!this.isBase;
      },
      surveyHistory(){
        this.isSurvey=!this.isSurvey;
      },
      // 分页导航
      handlePageChange(val) {
        this.$set(this.query, 'pageIndex', val);
        this.getData();
      },
      onSubmit() {
        console.log('submit!');
      },
      researchCheckSearch(){
        this.Successdialog=false
        //this.$router.push({name:'drugCatalog'});
        this.closePageTo(this.$store,this.$route,this.$router,'drugCatalog');
        self.close();
      },
//   封装一个方法
      countDown() {
        let THIS = this;
        THIS.time--;
      },
    },
    watch: {
      //   监听time的值
      time: function (newVal) {
        if (newVal === 0) {
          //this.$router.push({name:'drugCatalog'});
          this.closePageTo(this.$store,this.$route,this.$router,'drugCatalog');
          self.close();
          // this.Successdialog=false
        }
      },
    },
  };
</script>
